<?

require_once("phptvdb-1.0.1/TVDB.php");

header('Content-type: text/plain');

$shows = TV_Shows::search($_GET['q']);
$max = 10;
if (!empty($_GET['max']))
  $max = $_GET['max'];

print "{ results: [\n";

for ($i = 0; $i < min($max, count($shows)); $i++) {
//  $curShow = TV_Shows::findById($shows[$i]->id);
  print '{ id: "'.$shows[$i]->id.'", value: "'.$shows[$i]->seriesName.'", info: "'.date("Y", $shows[$i]->firstAired)."\" },\n";
}

print "] }\n";
?>
